package com.pow.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.pow.interceptor.LoginInterceptor;
@Configuration
public class CorsConfitg extends WebMvcConfigurerAdapter {
	//关键，将拦截器作为bean写入配置中
		@Autowired
		private LoginInterceptor loginInterceptor;

		@Override
		public void addInterceptors(InterceptorRegistry registry) {
			registry.addInterceptor(loginInterceptor)
					.addPathPatterns("/**").excludePathPatterns("/**/**");
		}

	public void addCorsMappings(CorsRegistry registry) {
		registry.addMapping("/**").allowedMethods("GET","DELETE","PUT","POST");
		}
}
